package org.ruanjj.functional;

import java.util.function.BiFunction;
import java.util.function.Function;

public class ConstructorReferenceTest {
    public static void main(String[] args) {
        //1.
        BiFunction<String, Integer,User> b = new BiFunction<String, Integer, User>() {
            @Override
            public User apply(String name, Integer age) {
                return new User(name,age);
            }
        };
        System.out.println(b.apply("Tony", 12));

        //2.
        BiFunction<String, Integer,User> b1 = User::new;
        System.out.println(b1.apply("Toy", 15));

        //数组引用
        Function<Integer,User[]> f = new Function<Integer, User[]>() {
            @Override
            public User[] apply(Integer length) {
                return new User[length];
            }
        };

        System.out.println(f.apply(10).length);

        //2.
        Function<Integer,User[]> ff = User[]::new;

        System.out.println(ff.apply(20).length);
    }

}
